<script lang="ts" setup>
import RemoteSelect from '@/components/base/form/remote-select.vue'
import type { WalletOrderSpec } from '@/apis/__generated/model/static'
import { walletPackageQueryOptions } from '@/views/wallet-package/wallet-package'
import { userLabelProp, userQueryOptions } from '@/views/user/store/user-store'

const emit = defineEmits<{ search: [value: WalletOrderSpec]; reset: [] }>()
const query = defineModel<WalletOrderSpec>('query', { required: true })
</script>
<template>
  <div class="search">
    <el-form inline label-width="80" size="small">
      <el-form-item label="用户">
        <remote-select
          :label-prop="userLabelProp"
          :query-options="userQueryOptions"
          v-model="query.creatorId"
        ></remote-select>
      </el-form-item>
      <el-form-item label="钱包套餐">
        <remote-select
          v-model="query.walletPackageId"
          :query-options="walletPackageQueryOptions"
          label-prop="name"
        ></remote-select>
      </el-form-item>
      <el-form-item label=" ">
        <div class="btn-wrapper">
          <el-button size="small" type="primary" @click="() => emit('search', query)">
            查询
          </el-button>
          <el-button size="small" type="warning" @click="() => emit('reset')"> 重置</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<style lang="scss" scoped>
:deep(.el-form-item) {
  margin-bottom: 5px;
}

.search {
  display: flex;
  flex-flow: column nowrap;
  width: 100%;

  .btn-wrapper {
    margin-left: 20px;
  }
}
</style>
